package cuShapes;

import java.awt.Color;
import javax.xml.bind.annotation.*;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Arc2D;
import java.awt.geom.Rectangle2D;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name="xmlarcline")
public class ArcLine extends PQLine{
	
	@XmlElement(required=true)
	private double angle;

	public ArcLine(){}
	
	public ArcLine(Point start, Point end, double ang, Color c) {
		color = new Color(c.getRGB());
		p1 = start;
		p2 = end;
		angle = ang;
	}
	
	public void drawLine(Graphics2D g2) {
		double w = Math.abs(p2.getX() - p1.getX());
		double h = Math.abs(p2.getY() - p1.getY());
		double x = (p1.getX() < p2.getX()) ? p1.getX() : p2.getX();
		double y = (p1.getY() < p2.getY()) ? p1.getY() : p2.getY();
		Rectangle2D ellipseBounds = new Rectangle2D.Double(x, y, w, h);
		g2.setColor(color);
		g2.draw(new Arc2D.Double(ellipseBounds, 0, angle, Arc2D.OPEN));
	}

	public Point getEnd() {
		return p2;
	}

	public Point getStart() {
		return p1;
	}

	public void setEnd(Point end) {
		p2 = end;
	}

	public void setStart(Point start) {
		p1 = start;		
	}

}
